#include <REGX52.H>
#include <INTRINS.H>
#include "LCD1602.h"
#include "onewire.h"
#include "delay.h"
#include "UART.h"

float T;
unsigned int intVal;

void main()
{
	unsigned char AckBit = 0;
	
	LCD_Init();
	
	LCD_ShowString(1,1,"Temperature");
	AckBit = OneWire_Init();
	LCD_ShowString(2,1,"Ack:");
	LCD_ShowNum(2, 5, AckBit, 1);
	
	while(1)
	{
		DS18B20_ConvertT();
		Delay(1);
		T = DS18B20_ReadT();
		
		if(T < 0){
			LCD_ShowChar(2,1,'-');
			T = -T;					//负数转换为正数
		}
		else{
			LCD_ShowChar(2,1,'+');
		}
		
		LCD_ShowNum(2, 2, T/16, 3);
		LCD_ShowChar(2, 5, '.');
		LCD_ShowNum(2, 6,(((unsigned long)T)*10000)/16%10000, 4);	//处理显示温度的小数部分
	}
}
